﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class AdminHomePage : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        //Check user login or not
        if (Session["Username"] == null)
        {
            Response.Redirect("Login.aspx");
        }

        SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["OPOConnectionString"].ToString());
        cnn.Open();

        SqlCommand cmd1 = new SqlCommand("Select count(*) from Account", cnn);
        SqlCommand cmd2 = new SqlCommand("Select count(*) from Branch", cnn);
        SqlCommand cmd3 = new SqlCommand("Select count(*) from City", cnn);
        SqlCommand cmd4 = new SqlCommand("Select count(*) from TypeOfDeliver", cnn);
        SqlCommand cmd5 = new SqlCommand("Select count(*) from TypeOfMail", cnn);
        SqlCommand cmd6 = new SqlCommand("Select count(*) from DistanceOfMail", cnn);
        SqlCommand cmd7 = new SqlCommand("Select count(*) from WeightOfMail", cnn);
        SqlCommand cmd8 = new SqlCommand("Select count(*) from Feedback", cnn);

        Int32 acc = (Int32)cmd1.ExecuteScalar();
        lblAccount.Text = Convert.ToString(acc);
        Int32 brc = (Int32)cmd2.ExecuteScalar();
        lblBranch.Text = Convert.ToString(brc);
        Int32 city = (Int32)cmd3.ExecuteScalar();
        lblCity.Text = Convert.ToString(city);
        Int32 tod = (Int32)cmd4.ExecuteScalar();
        lblDType.Text = Convert.ToString(tod);
        Int32 tom = (Int32)cmd5.ExecuteScalar();
        lblMType.Text = Convert.ToString(tom);
        Int32 dis = (Int32)cmd6.ExecuteScalar();
        lblDistance.Text = Convert.ToString(dis);
        Int32 wgt = (Int32)cmd7.ExecuteScalar();
        lblWeight.Text = Convert.ToString(wgt);
        Int32 fb = (Int32)cmd8.ExecuteScalar();
        lblFeedback.Text = Convert.ToString(fb);



        
    }
}